package com.sl.au.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.EventReport;
import com.sl.au.entity.ViewForEventReportTask;;

public interface ViewForEventReportTaskRepository extends JpaRepository<ViewForEventReportTask, String>{

	@Query("select a from ViewForEventReportTask a where a.reportContent like %?1% or a.eventName like %?1%")
	Page<ViewForEventReportTask> getByKey(String key, Pageable pageable);
	
	@Query("select a from ViewForEventReportTask a where a.reportEventVariableTitle=?1 and a.eventTaskStateTitle=?1 and (a.reportContent like %?2% or a.eventName like %?2%)")
	Page<ViewForEventReportTask> getByEventVariableAndKey(String eventVariable,String key, Pageable pageable);
	
	@Query("select a from ViewForEventReportTask a where a.reportEventVariableTitle=?1 and a.eventTaskStateTitle=?1")
	Page<ViewForEventReportTask> getByEventVariable(String eventVariable, Pageable pageable);
	
	@Query("select a from ViewForEventReportTask a where a.reportEventToNetGrid = ?1 and a.eventTaskStateTitle = ?2 and a.reportAccTime > ?3 and a.reportAccTime < ?4 order by a.reportAccTime desc")
	List<ViewForEventReportTask> getReportByGrid(String gridId, String type, Date begin, Date end);
}
